package com.jy.api.dao;

import com.jy.api.domain.NetScheduling;
import com.jy.api.domain.NetSchedulingTransaction;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * @author xiaohua
 * @data 2024/9/9 0009 11:03
 */
public interface NetSchedulingTransactionDao extends JpaRepository<NetSchedulingTransaction, Integer>, JpaSpecificationExecutor<NetSchedulingTransaction> {
    NetSchedulingTransaction findTop1ByStoreIdAndAreaIdAndAddTimeBetweenOrderByIdDesc(String storeId, int areaId, Date startOfToday, Date endOfTodayDateTime);

    List<NetSchedulingTransaction> findByTypeAndStoreIdAndAddTimeBetween(int type, String storeId, Date startOfToday, Date endOfTodayDateTime);

    @Transactional
    @Modifying
    void deleteByAddTimeLessThanEqual(Date time);

    List<NetSchedulingTransaction> findByAddTimeLessThanEqual(Date todayDayByHour);


    long countByStoreIdAndAreaIdAndType(String storeId, int areaId, int type);


    List<NetSchedulingTransaction> findAllByStoreIdAndAreaIdAndTypeAndAddTimeBetweenOrderByAddTimeAsc(String storeId, int areaId, int type, Date startOfToday, Date endOfTodayDateTime);
}
